package tech.summerly.weather.component.adapter.floors

import android.view.LayoutInflater
import android.view.ViewGroup
import tech.summerly.weather.R
import tech.summerly.weather.component.fragments.LiveWeatherFragment
import tech.summerly.weather.model.Region
import tech.summerly.weather.util.ViewHolder
import tech.summerly.weather.util.inTransaction

class LiveStreamFloor : BaseFloor<LiveStream>() {

    override fun onCreateViewHolder(inflater: LayoutInflater, parent: ViewGroup): ViewHolder {
        return createHolder(R.layout.floor_live_stream, inflater, parent)
    }

    override fun onBindViewHolder(holder: ViewHolder, item: LiveStream) = with(holder.itemView) {
        setOnClickListener {
            // navigation to LiveWeatherFragment
            getTowerAdapter().activity.supportFragmentManager.inTransaction {
                add(android.R.id.content, LiveWeatherFragment.newInstance(item.region), LiveWeatherFragment.TAG)
                addToBackStack(LiveWeatherFragment.TAG)
            }
        }
        Unit
    }
}


class LiveStream(val region: Region)